<template>
    <div class="cloud-store-list">
        <div class="header-box">
            <div class="header-left">
                <div class="title">云店列表</div>
            </div>
        </div>
        <div class="list-box">
            <div class="list-row" v-for="item in yd_data" :key="item.id">
                <div class="content-box">
                    <div class="img-box">
                        <img :src="item.logo ? item.logo : img_buf" />
                        <div class="name">{{ item.name }}</div>
                    </div>
                    <div class="but">
                        <el-popover placement="top" width="100" trigger="click">
                            <div class="qr-code">
                                <div class="img-box">
                                    <img
                                        :src="
                                            item.wxacode
                                                ? item.wxacode
                                                : img_buf
                                        "
                                    />
                                </div>
                            </div>
                            <el-button plain slot="reference">二维码</el-button>
                        </el-popover>
                    </div>
                    <div class="but but-a">
                        <el-button type="primary" plain @click="goPage(item)"
                            >管理</el-button
                        >
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import config from "@/js/conf/Config.js";
import goPage from "@/js/GoPage.js";
import staticConst from "@/js/const/StaticConst.js";

export default {
    props: [],
    components: {},
    computed: {},
    data() {
        return {
            img_buf: staticConst.GOOD_IMG,
            yd_data: [],
        };
    },
    created() {
        uni.setLeftWindowStyle({ width: "0px" });
        this.getYdlistFun();
    },
    mounted() {},
    methods: {
        // 获取云店列表
        async getYdlistFun() {
            let url = config.YUN_SHOP_LS;
            let param = {};
            let res = await this.$api({ url: url, data: param });
            if (res.status == 1 && res.data) {
                if (res.data.length == 1) {
                    goPage.goNavTo(
                        `/pages/cloudShop/index?pageType=2&idyun=${res.data[0].id}`
                    );
                } else {
                    this.yd_data = res.data;
                }
            }
        },
        goPage(item) {
            goPage.goNavTo(
                `/pages/cloudShop/index?pageType=1&idyun=${item.id}`
            );
        },
    },
};
</script>
<style lang="scss">
.qr-code {
    .img-box {
        width: 100%;
        height: 150px;
        img {
            width: 100%;
            height: 100%;
        }
    }
    .tis-txt {
        margin-top: 10px;
        font-size: 12px;
        text-align: center;
    }
}
</style>
<style lang="scss" scoped >
.cloud-store-list {
    height: 100%;
    margin-left: 72px;
    .header-box {
        height: 50px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        border-bottom: 1px #e8dcdc solid;
        padding: 0 10px;
        padding-right: 20px;
        display: flex;
        .header-left {
            display: flex;
            .back {
                font-size: 20px;
                margin-right: 10px;
                cursor: pointer;
            }
            .title {
                font-size: 18px;
            }
        }
    }
    .list-box {
        padding: 20px;
        display: flex;
        flex-wrap: wrap;
        .list-row {
            width: 200px;
            height: 300px;
            border-radius: 5px;
            border: 1px solid #d7d7d7;
            background: #f7f7f7;
            margin-right: 20px;
            margin-bottom: 20px;
            .content-box {
                padding-top: 40px;
                .img-box {
                    text-align: center;
                    img {
                        width: 80px;
                        height: 80px;
                        object-fit: cover;
                        border-radius: 50%;
                        overflow: hidden;
                        border: 1px solid #d7d7d7;
                    }
                }
                ::v-deep.but {
                    width: 100%;
                    text-align: center;
                    margin-top: 20px;
                    &.but-a {
                        .el-button {
                            padding: 12px 26px;
                        }
                    }
                }
            }
        }
    }
}
</style>
